package enums;

public enum ColorEnum {
    RED("红色",1),YELLOW("黄色",2),BLUE("蓝色",3),GREEN("绿色",4);
    private String name;
    private int index;

    private ColorEnum(String name,int index){
        this.name=name;
        this.index=index;
    }

    @Override
    public String toString() {
        return String.valueOf(index);
    }


    public static String getColorName(int index){
        for(ColorEnum colorEnum:ColorEnum.values()){
            if(index==colorEnum.getIndex()){
                return colorEnum.getName();
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
